package com.quyl.poi.util;

public class ProcessBarUtil {

    final static int maxIndex = 20;

    public static void printCurrentNum(int i, int curNum, int totalNum) {
        String num = "000" + i;
        num = num.substring(num.length() - 3);
        StringBuffer s = new StringBuffer();
        s.append("当前进度");
        s.append(num + "%[");
        focusGoto();
        int prec = (i * 100) / 100;
        for (int index = 0; index < maxIndex; index++) {
            int c = (index * 100) / maxIndex;
            if (c < prec) {
                s.append("··");
            } else {
                s.append(" ");
            }
        }
        s.append("]");
        s.append("执行文件：" + curNum + "/" + totalNum);
        System.out.print(s.toString());
    }

    public static void focusGoto() {
        for (int i = maxIndex + 30; i > 0; i--) {
            System.out.print('\b');
        }
    }
}
